package com.dshore.messagecenter.controller.warning;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dshore.messagecenter.log.LogAnnotation;
import com.dshore.messagecenter.model.system.ResponseResult;
import com.dshore.messagecenter.model.system.SysDict;
import com.dshore.messagecenter.model.warning.MrWarningPerson;
import com.dshore.messagecenter.model.warning.MrWarningThreshold;
import com.dshore.messagecenter.service.warning.WarningThresholdService;
import com.dshore.messagecenter.util.Page;

@Controller
@RequestMapping("/warningThreshold")
public class WarningThresholdController {
	
	@Autowired
	private WarningThresholdService warningThresholdService;
	
	/**
	 * 页面
	 * @return
	 */
	@RequestMapping(value="/toWarningThreshold")
	public String module() {
		return "warning/mrWarningThreshold";
	}
	
	/**
	 * 获取监控项下拉框数值
	 * @return
	 */
	@RequestMapping(value="/getMonitoringItems")
	@ResponseBody
	public List<SysDict> getMonitoringItems(String objType){
		return warningThresholdService.getMonitoringItems(objType);		
	}
	
	/**
	 * 获取监控类型下拉框值
	 * @return
	 */
	@RequestMapping(value="/getMonitoringType")
	@ResponseBody
	public List<SysDict> getMonitoringType(){
		return warningThresholdService.getMonitoringType();
	}
	
	/**
	 * 扫描间隔
	 */
	@RequestMapping(value="/getMonitoringPeriod")
	@ResponseBody
	public List<SysDict> getMonitoringPeriod(){
		return warningThresholdService.getMonitoringPeriod();
	}
	
	/**
	 * 监控阈值设置
	 */
	@RequestMapping(value="/getThreshold")
	@ResponseBody
	public List<SysDict> getThreshold(String objType,String kpiType){
		return warningThresholdService.getThreshold(objType,kpiType);
	}
	
	/**
	 * 预警通知人下拉框值
	 */
	@RequestMapping(value="/getPrincipal")
	@ResponseBody
	public List<MrWarningPerson> getPrincipal(){
		return warningThresholdService.getPrincipal();
	}
	
	/**
	 * 通知方式下拉框值
	 */
	@RequestMapping(value="/getWarningType")
	@ResponseBody
	public List<SysDict> getWarningType(){
		return warningThresholdService.getWarningType();
	}
	
	/**
	 * 删除
	 * @param ids
	 */
	@LogAnnotation(methodType="删除",targetType="预警阈值",argsName="ids",fieldName="KPI_ID",tableName="T_MR_WARNING_THRESHOLD",thresholdDeletionSpecial="kpi_type,monitor_type")
	@RequestMapping(value="/deleteByIds")
	@ResponseBody
	public ResponseResult<Void> deleteByIds (String ids) {
		return warningThresholdService.deleteByIds(ids);
	}
	
	/**
	 * 页面表格数据展示
	 * @param warningThreshold
	 * @return
	 */
	@RequestMapping(value="/getWarningThreshold",method=RequestMethod.POST)
	@ResponseBody
	public Page<MrWarningThreshold> getWarningPerson(@RequestBody MrWarningThreshold warningThreshold){
		return warningThresholdService.queryListAll(warningThreshold);
	}
	
	@RequestMapping(value="/getById",method=RequestMethod.POST)
	@ResponseBody
	public MrWarningThreshold getById(String id) {
		return warningThresholdService.getById(id);
	}
	
	/**
	 * 新增
	 * @param warningThreshold
	 */
	@LogAnnotation(methodType="新增",targetType="预警阈值",argsName="kpiName")
	@RequestMapping(value="/addWarningThreshold",method=RequestMethod.POST)
	@ResponseBody
	public ResponseResult<Void> addWarningThreshold(MrWarningThreshold warningThreshold) {
		return warningThresholdService.addWarningThreshold(warningThreshold);
	}
	
	/**
	 * 修改
	 * @param warningThreshold
	 * @return
	 */
	@LogAnnotation(methodType="修改",targetType="预警阈值",argsName="kpiName")
	@RequestMapping(value="/changeWarningThreshold",method=RequestMethod.POST)
	@ResponseBody
	public ResponseResult<Void> changeWarningThreshold(MrWarningThreshold warningThreshold) {
		return warningThresholdService.changeWarningThreshold(warningThreshold);
	}
	
	/**
	 * 获取单位
	 * @return
	 */
	@RequestMapping(value="/getUnit")
	@ResponseBody
	public List<SysDict> getUnit(String objType,String kpiType){
		return warningThresholdService.getUnit(objType,kpiType);
		
	}
}
